<template>
<div>
  <el-card class="box-card">
    <template #header>
      <div class="card-header">
        <span>订阅详情</span>
        <el-button type="primary" size="small" @click="refresh"
          style="float:right;margin-left: 10px;">刷新</el-button>   
         <el-button type="primary" size="small" @click="editFollow"
                  style="float:right;margin-left: 10px;">编辑</el-button>
        <el-button type="primary" size="small" @click="delFollow"
          style="float:right;margin-left: 10px;">删除</el-button>        
      </div>
    </template>
    <el-descriptions
      class="margin-top"
      :column="3"
      :size="size"
      border
    >
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">
            <el-icon :style="iconStyle">
              <user />
            </el-icon>
            标题
          </div>
        </template>
        {{ rssMain.title }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template #label>
          <div class="cell-item">
            <el-icon :style="iconStyle">
              <tickets />
            </el-icon>
            博客链接
          </div>
        </template>
        <el-link :href="rssMain.link" target="_blank">{{
          rssMain.link
        }}</el-link>
      </el-descriptions-item>
    </el-descriptions>
  </el-card>
  <EditFollow ref="editFollow" @submit="queryFollow"></EditFollow>
</div>
</template>

<script>
import { $tip } from "@/base/util/ui";
import EditFollow from "./EditFollow.vue";

import {
  readRssOne,
  queryFollow,
  addFetch,
  readHis,
  updateRss,
  delFollow,
} from "@/common/api/rss";

export default {
  props: ["rssMain","follow"],
  components:{
    EditFollow
  },
  data() {
    return {
      count: 0,
      tableData: [],
    };
  },
  methods: {
    queryFollow() {
      this.$emit('submitChange')
    },
    editFollow() {
      this.$refs.editFollow.init(this.follow);
    },
    delFollow() {
      delFollow({ rssId: this.follow.rssId }).then((res) => {
        if (res) {
          $tip.success("删除订阅成功！");
          this.$emit('submitChange')
        }
      });
    },
    refresh(){
      console.log('this.rssMain :>> ', this.rssMain);
      let param = { rssId: this.rssMain.rssId };
      addFetch(param).then((res) => {
        if(res){
          this.$emit('submitChange')
        }else{
          $tip.error("刷新失败！"+res.msg);
        }
      })

    }
  },
  mounted() {
    // 在其他方法或是生命周期中也可以调用方法
  },
};
</script>

<style scoped></style>
